/**
* \file DGVAliases.h
*
* \brief This file defines all the aliases and frequently used functions and variables.
* \author Shekhar S. Chandra, 2008-9
*
* This file is part of DGV Library.
*
* DGV is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DGV is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DGV.  If not, see <http://www.gnu.org/licenses/>.
*/

/**
* \mainpage Discrete Geometry Viewer (DGV) API
*
* \section intro_sec Introduction
*
* The DGV library essentially binds together three important libraries.
* Qt GUI Library for user interfaces. The VTK Visualisation library for OpenGL data plot rendering, and the
* Blitz++ numerical library for performance in calculations and to clean up array syntax/code.
*
* It is designed for fast and lightweight visualisation with no prior knowledge of VTK or computer graphics. The
* test programs demonstrate the usage of the classes in every scientific visualisation.
*
* \section features Features
*
* Classes are present that display images, surface plots and volume plots from simple 1D line, 2D image, 2D surface and 3D arrays via DGVPlot, DGVImageVTK,
* DGVSurfacePlotVTK and DGVVolumePlotVTK classes respectively.
* Fourier Transforms of the arrays are also provided (DGVFourierTransform class) as well as operations on data via GUIs.
* Some animation capability is also implemented for line and surface plots.
* Common GUI elements are also implemented such as drag and drop and recent files list.
* Casting from Blitz arrays to and from Qt and VTK objects are done using
* Blitz caster classes DGVBlitzArrayCaster and DGVBlitzArrayCasterVTK objects.
*/

#ifndef DGVALIASES_H_INCLUDED
#define DGVALIASES_H_INCLUDED

#include <limits>
#include <stdexcept> ///Include stdexcept to handle conversion exceptions
#include <blitz/array.h>

#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
    #include <windows.h>
#else
    #include <unistd.h>
#endif

#include "DGVGlobal.h"

using namespace blitz;
using namespace std;

#ifndef DEF_IMAGE_TYPE
#define DEF_IMAGE_TYPE 1
typedef double imageType;
#endif

/*#ifndef DEF_IMAGE_TYPE_LIMITS
#define DEF_IMAGE_TYPE_LIMITS 1
numeric_limits<imageType> imageTypeLimits;
#endif*/

const float version = static_cast<float>(0.3);
const int minWindowSize = 256;
const int maxAASamples = 6; //Anti-Aliasing

#ifndef DEF_BADSTR
#define DEF_BADSTR 1
/**
* \class BadStrConversion
* Exception Handler for stringify function. Thrown if the conversion from
* numeric to string is unsuccessful.
*/
class BadStrConversion : public runtime_error {
public:
    BadStrConversion(const string& s)
        : runtime_error(s)
    { }
};
#endif

#ifndef DEF_NUMTOSTR
#define DEF_NUMTOSTR 1
/**
* \fn numToString(double num)
* Number to string converter
*/
inline string numToString(double num)
{
    ostringstream toString;
    if (!(toString << num))
        throw BadStrConversion("numToString(double)");
    return toString.str();
}
#endif

#ifndef DEF_NUMOFCORES
#define DEF_NUMOFCORES 1
/**
* \fn numOfProcessors()
* Number of processors or cores on the machine.
*/
inline unsigned numOfProcessors()
{
    unsigned cores = 1;

#ifdef _WIN32
    SYSTEM_INFO sysinfo;
    GetSystemInfo( &sysinfo );

    cores = sysinfo.dwNumberOfProcessors;
#else
    cores = sysconf( _SC_NPROCESSORS_ONLN );
#endif

    return cores;
}
#endif

#endif // DGVALIASES_H_INCLUDED
